const api = require("../../utils/request");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    bannerList: [
      "https://img13.360buyimg.com/cms/jfs/t1/89586/17/640/196123/5db15122E96399d8b/1d90d17e5cd5618c.jpg!q80.webp",
      "https://img14.360buyimg.com/cms/jfs/t1/74857/23/13754/74574/5db151b9Efee224d5/1857d28f18389ef2.jpg!q80.webp",
      "https://img14.360buyimg.com/cms/jfs/t1/70636/16/13845/116147/5db15187Eeff649d6/1126cdbcd5c3487e.jpg!q80.webp",
      "https://img12.360buyimg.com/cms/jfs/t1/55309/19/14238/92652/5db16581E3a8073c7/789b03b9548155cf.jpg!q80.webp",
      "https://img13.360buyimg.com/cms/jfs/t1/39330/33/13992/109636/5db162c6E0c1a750c/c8bc1a7036056ffc.jpg!q80.webp",
      "https://img13.360buyimg.com/cms/jfs/t1/62009/28/13662/95125/5db15eb1Eb72ec901/6411ab37210ba505.jpg!q80.webp",
      "https://img10.360buyimg.com/cms/jfs/t1/54797/35/14406/95993/5db15155Eefcea47a/bedfe80f3d50c5bd.jpg!q80.webp"
    ],
    grid: [{
      image: "/images/gg.png",
      name: "公告"
    }, {
      image: "/images/ys.jpg",
      name: "原神"
    }, {
      image: "/images/ys.jpg",
      name: "原神"
    }, {
      image: "/images/ys.jpg",
      name: "原神"
    }, ],
    list: [],
    searchValue: ""
  },
  noticeClick(e) {
    if (e.currentTarget.dataset.index == 0) {
      wx.navigateTo({
        url: '/pages/notice/notice',
      })
    }else{
      wx.navigateTo({
        url: '/pages/yuanshen/yuanshen',
      })
    }
  },
  searchValue(e) {
    this.setData({
      searchValue: e.detail.value
    })
  },
  searchClick() {
    if (this.data.searchValue) {
      wx.navigateTo({
        url: '/pages/searchDetail/searchDetail?searchValue=' + this.data.searchValue,
      })
    }
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    
    api.goodsList({
      data: {
        pageNum: parseInt(Math.random()*(8-1)+1),
        pageSize: 10
      }
    }).then(res => {
      this.setData({
        list: res.data.data.records
      })
    })

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})